package main

import (
	"encoding/json"
	"fmt"
)

type EsData struct {
	TagInfoData TagInfoData `json:"tag_info"`
}

type TagInfoData map[string]TagInfo

type TagInfo struct {
	InShopWhiteList  bool               `json:"in_shop_white_list"` //白名单
	DeliveryTime     int                `json:"delivery_time"`      //发货时间，单位小时
	Times            int                `json:"times"`              //X期免息
	QuantityDiscount map[string]float64 `json:"quantity_discount"`  //多件打折
}

func main() {
	jsonStr := `{"38":{"times":24},"1001":{"delivery_time":120,"in_shop_white_list":true,"times":24,"quantity_discount":{"2":0.85}}}`

	data := &TagInfoData{}
	err := json.Unmarshal([]byte(jsonStr), data)
	if err != nil {
		panic(err)
	}

	fmt.Printf("data = %+v\n", data)

	tagInfo()
}

func tagInfo() {
	jsonStr := `{"a":"b","tag_info":{"38":{"times":24},"1001":{"delivery_time":120,"in_shop_white_list":true,"times":24,"quantity_discount":{"2":0.85}}}}`

	data := &EsData{}
	err := json.Unmarshal([]byte(jsonStr), data)
	if err != nil {
		panic(err)
	}
	fmt.Printf("data = %+v\n", data)
}
